package com.zzyl.controller;

import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.entity.NursingLevel;
import com.zzyl.entity.NursingPlan;
import com.zzyl.service.NursingPlanService;
import com.zzyl.vo.NursingPlanVo;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Description NursingPlanController
 * @Author Wen Jie
 * @Date 2024-09-06
 */
@RestController
@RequestMapping("/nursing")
@Api(tags = "护理计划模块")
public class NursingPlanController extends BaseController{
    @Autowired
    private NursingPlanService nursingPlanService;
    @GetMapping("/plan")
    @ApiOperation("查询所有护理计划")
    public ResponseResult<List<NursingPlanVo>> getAll(){
        List<NursingPlanVo> nursingPlanVos = nursingPlanService.getAll();
        return success(nursingPlanVos);
    }
    @PostMapping("/plan")
    @ApiOperation("添加护理计划")
    public ResponseResult addNursingPlan(
            @ApiParam(value = "护理计划信息",required = true)
            @RequestBody NursingPlanVo nursingPlanVo){
        nursingPlanService.addNursingPlan(nursingPlanVo);
        return success();
    }

    @GetMapping("/plan/search")
    @ApiOperation("查询护理计划列表")
    public ResponseResult<PageResponse<NursingPlanVo>> getPage(
            @ApiParam(value = "计划名称")
            @RequestParam(value ="name",required = false) String name,
            @ApiParam(value = "状态")
            @RequestParam(value = "status",required = false) Integer status,
            @ApiParam(value = "当前页码")
            @RequestParam(value = "pageNum",defaultValue = "1") Integer pageNum,
            @ApiParam(value = "每页大小")
            @RequestParam(value = "pageSize",defaultValue = "10") Integer pageSize
    ){
        PageResponse<NursingPlanVo> pageResponse = nursingPlanService.getPage(name,status,pageNum,pageSize);
        return success(pageResponse);
    }

    @GetMapping("/plan/{id}")
    @ApiOperation("根据id查看护理计划")
    public ResponseResult<NursingPlanVo> getById(@ApiParam(value = "护理计划id") @PathVariable Long id){
        NursingPlanVo nursingPlanVo = nursingPlanService.getById(id);
        return success(nursingPlanVo);
    }

    @PutMapping("/plan/{id}")
    @ApiOperation("修改护理计划")
    public ResponseResult updateNursingPlan(@ApiParam(value = "护理计划信息") @RequestBody NursingPlanVo nursingPlanVo){
        nursingPlanService.updateNursingPlan(nursingPlanVo);
        return success();
    }
    @DeleteMapping("/plan/{id}")
    @ApiOperation("删除护理计划")
    public ResponseResult deleteNursingPlan(@ApiParam(value = "护理计划id") @PathVariable Long id){
        nursingPlanService.deleteNursingPlan(id);
        return success();
    }

    @PutMapping("{id}/status/{status}")
    @ApiOperation("修改护理计划状态")
    public ResponseResult updateStatus(@ApiParam(value = "护理计划id") @PathVariable Long id,
                                      @ApiParam(value = "状态") @PathVariable Integer status){
        nursingPlanService.updateStatus(id,status);
        return success();
    }

}
